<ion-content>
    <ion-refresher [enabled]="loaded" (ionRefresh)="refreshData($event)">
        <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
    </ion-refresher>

    <core-search-box (onSubmit)="search($event)" (onClear)="clearSearch($event)" [placeholder]=" 'addon.messages.contactname' | translate" autocorrect="off" spellcheck="false" lengthCheck="2" [disabled]="!loaded"></core-search-box>

    <core-loading [hideUntil]="loaded" [message]="loadingMessage">
        <core-empty-box *ngIf="!hasContacts && searchString == ''" icon="person" [message]="'addon.messages.contactlistempty' | translate"></core-empty-box>

        <core-empty-box *ngIf="!hasContacts && searchString != ''" icon="person" [message]="'addon.messages.nousersfound' | translate"></core-empty-box>

        <ion-list *ngFor="let contactType of contactTypes" no-margin>
            <ng-container *ngIf="contacts[contactType] && (contacts[contactType].length > 0 || contactType === searchType)">
                <ion-item-divider>
                    <h2>{{ 'addon.messages.type_' + contactType | translate }}</h2>
                    <ion-note item-end>{{ contacts[contactType].length }}</ion-note>
                </ion-item-divider>
                <ng-container *ngFor="let contact of contacts[contactType]">
                    <!-- Don't show deleted users -->
                    <a ion-item text-wrap *ngIf="contact.profileimageurl || contact.profileimageurlsmall"  [title]="contact.fullname" (click)="gotoDiscussion(contact.id)" [class.core-split-item-selected]="contact.id == discussionUserId" class="addon-messages-conversation-item">
                        <ion-avatar core-user-avatar [user]="contact" item-start [checkOnline]="contact.showonlinestatus"></ion-avatar>
                        <h2>{{ contact.fullname }}</h2>
                    </a>
                </ng-container>
            </ng-container>
        </ion-list>
    </core-loading>
</ion-content>
